{extend name="Public/layout2.html"}
{block name="body"}

    <blockquote class="layui-elem-quote">
    <span class="layui-breadcrumb">
  					<a href="../">首页</a>

  					<a><cite>导航元素</cite></a>
					</span>
    </blockquote>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>响应式的表单集合</legend>
    </fieldset>
    <div style="padding: 20px;width: 90%">

        <table class="layui-table" id="table1">

            <thead>
            <tr>
                <th>id</th>
                <th>name</th>
                <th>操作</th>

            </tr>
            </thead>

        </table>
    </div>
{/block}


{block name="jslink"}
    {__block__}

    <script type="application/javascript">
        var table = null;

        /**
         * 删除方法
         * @param id
         * @param name
         */
        function del(id, name) {
            var url = "{:url('index/fuck/deletebyid')}";
            var data = {
                id: id
            };


            $.post(url, data, function(data) {
                layer.msg('删除成功!');
                table.ajax.reload();
            })

        }
        function refreshTable() {
            table.ajax.reload();
        }

        function showAddLayer() {
            var index = layer.open({
                type: 2,
                title: '新增界面',
                content:"{:url('index/member/addmember')}",
                area: ['500px', '300px'],
                scrollbar: false
            });

        }

        $(function() {
            //        laypage({
            //            cont: 'demo1'
            //            , pages: 100 //总页数
            //            , groups: 5 //连续显示分页数,
            //            , jump: function (obj, first) {
            //                //得到了当前页，用于向服务端请求对应数据
            //                var curr = obj.curr;
            //                layer.msg(curr);
            //            }
            //        });
            table = $('#table1').DataTable({
                "dom": 'lf<"toolbar">rt<ip>',
                "ajax": {
                    "url": "{:url('index/member/getlist')}",

                },
                //            "ajax":"{:url('index/fuck/getlist')}",
                "columns": [{
                    "data": "id"
                }, {
                    "data": "name"
                }, {
                    "data": null
                },

                ],
                "columnDefs": [{
                    "targets": -1,
                    "render": function(data, type, row, meta) {
                        var id = '"' + row.id + '"';
                        var fun2 = "del(" + id + ")";


                        return '<btn class="layui-btn layui-btn-small"  onclick=' + fun2 + '><i class="layui-icon">&#xe640;</i>删除</btn>';
                    }
                }],
            });
            $("div.toolbar").html('<btn onclick="showAddLayer()"  style="margin-left: 20px" class="layui-btn"">新增</btn>');


        });
    </script>
{/block}

